package com.cc.crm.service.impl;

import com.cc.crm.mapper.CustomerMapper;
import com.cc.crm.pojo.Customer;
import com.cc.crm.service.CustomerService;
import com.cc.crm.vo.CustomerVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program:
 * @ClassName:
 * @description:
 * @author: zgc
 * @date:
 * @Version 1.0
 **/
@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;
    //查询客户
    @Override
    public PageInfo<Customer> selectCustomer(CustomerVo customerVo) {
        //开启查询
        if (customerVo.getPageNum() != null && customerVo.getPageSize() != null){
            PageHelper.startPage(customerVo.getPageNum(),customerVo.getPageSize());
        }
        List<Customer> customerList = customerMapper.selectCustomer(customerVo);
        PageInfo<Customer> pageInfo = new PageInfo<>(customerList);
        return pageInfo;
    }

    @Override
    public int insertCustomer(Customer customer) {
        return customerMapper.insertCustomer(customer);
    }

    @Override
    public int deleteCustomer(Customer customer) {
        return customerMapper.deleteCustomer(customer);
    }
    
    //修改客户信息
    @Override
    public int updateCustomer(Customer customer) {
        return customerMapper.updateCustomer(customer);
    }
    
}
